<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        #text{
            width: 600px;
            height: 50px;
            line-height: 50px;
            font-size:30px;
        }
        #box{
            width: 600px;
            height: 50px;
            line-height: 50px;
            font-size:30px;
            border: 1px solid #000;
        }
    </style>
</head>
<body>
    <h1>实时同步输入文本</h1>
    <hr>

    <input type="text" id="text">

    <br><br>
    <div id="box"></div>

    <script>
        var input = document.getElementById('text');
        var div = document.getElementById('box');

        // 显示文字
        // input.onchange = function() {
        //     div.innerHTML = input.value;
        // }

        // 实时显示文字
        input.oninput = iii;
        input.onpropertychange = iii;
        function iii(){
            div.innerHTML = input.value;
        }

        // 选中时触发
        input.onselect = function() {
            alert('啊,我中弹了!!!');
        }

    </script>
</body>
</html>